import b_position
import b_velocity
import b_acceleration
import b_boundary
import b_displacement

class Node(object):
	def __init__(self, data, name, position=None, velocity=None, fields=[], boundary=None, loads=[], mass=0, *arguments, **keywords):
		self.data = data
		self.name = name
		if position is None:
			self.position = b_position.Position(self.data)
		else:
			self.position = position
		self.displacement = b_displacement.Displacement(self.data)
		if velocity is None:
			self.velocity = b_velocity.Velocity(self.data)
		else:
			self.velocity = velocity
		self.acceleration = b_acceleration.Acceleration(self.data)
		self.fields = fields
		self.boundary = boundary
		self.loads = loads
		self.mass = mass
	
	def deleteNode(self):
		for member in self.data.members.values():
			for node in member.nodes:
				if node is self:
					member.deleteMember()
		del self.data.nodes[self.name]
	
	def __repr__(self):
		return "{Node: {name: %s, position: %s, velocity: %s, fields: %s, bounds: %s, loads: %s, mass: %s}}" % (self.name, self.position, self.velocity, self.fields, self.boundary, self.loads, self.mass)
